<?
ob_start();
include("common/header.html");
include("common/left.html");
$out_html=ob_get_contents();
ob_end_clean();
include("common/page.php");
include("class/OrderRecord.php");
include("class/ProOrder.php");
$atype= 'sale';// 导出文件名判断条件
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s= new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$memberID=$_SESSION['sid'];

// 获取对应的供应商
if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors' || $_REQUEST['tjs']==4){
	include 'getDistors.php';
    $DistorsNames = getRetail($GLOBALS['le']);
	//print_r($DistorsNames);
	$dTypeName = '供应商';
	// 异步获取对应的供应商
	if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors'){
		echo json_encode(array('s'=>'success','d'=>$DistorsNames));
		exit;
	}
}

$str="select id,imgpath from uu_land";
$images=array();
$GLOBALS['le']->query($str);
while($row=$GLOBALS['le']->fetch_assoc()){
	$images[$row['id']]=$row['imgpath'];
}
$str="select id,dname from pft_member where dtype=0";
$anames=array();
$GLOBALS['le']->query($str);
while($row=$GLOBALS['le']->fetch_assoc()){
	$anames[$row['id']]=$row['dname'];
}
//print_r($anames);
$pOrder=saleProOrderObject($memberID,$s,$_SESSION['sdtype']);
$v['title']="已卖出的产品";
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:15;
// 导出订单设置
if(isset($_REQUEST['act']) && $_REQUEST['act']=="Export" && isset($_REQUEST['LoadEc'])){
	$currentPage=$_REQUEST['LoadEc'];
	$pageSize=1000;
	set_time_limit(1800);
}
$r=$pOrder->_orderlist($currentPage,$pageSize);
// print_r($r);
$fids=array();
foreach($r as $key=>$row){
	
	if($r[$key]['mainOrder']->UUlid!=72){
		if($r[$key]['mainOrder']->UUstatus!=1){
			$r[$key]['mainOrder']->UUordertel=substr_replace((string)$r[$key]['mainOrder']->UUordertel,"****",3,4);
		}
	}
	
	
	$_fids=explode(",",$r[$key]['mainOrder']->UUaids);//echo $r[$key]['mainOrder']->UUaids." ".$r[$key]['mainOrder']->UUordernum;
	foreach($_fids as $_key=>$val){
		if($val==$memberID){//echo $key." ".$r[$key]['mainOrder']->UUordernum;
			if(isset($_fids[$_key+1])){//echo $_fids[2]." ".$r[$key]['mainOrder']->UUordernum;
				$r[$key]['mainOrder']->fid=$_fids[$_key+1];
				$fids[]=$_fids[$_key+1];
			}
			break;
		}
	}
}

include("loadExcel.php");
echo $out_html;
// print_r($r);
if($fids){
	$sel="select id,dname from pft_member where id in (".implode(",",$fids).")";
	$fnames=array();
	$GLOBALS['le']->query($sel);
	while($row=$GLOBALS['le']->fetch_assoc()){
		$fnames[$row['id']]=$row['dname'];
	}
}
// 判断订单是否为主订单  true为主订单
function isMainOrder($field){
	return ($field=='main') ? true:false;
}
$count=$pOrder->orderlistTotal();
$str="select account from pft_member where id=$memberID";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$account=$GLOBALS['le']->f("account");
include("tpl/orderLists_t.tpl");
include("common/footer.html");
?>